package com.ruoyi.web.ydz.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.web.ydz.domain.GradeRule;
import com.ruoyi.web.ydz.mapper.GradeRuleMapper;
import com.ruoyi.web.ydz.service.IGradeRuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 等级规则Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-03
 */
@Service
public class GradeRuleServiceImpl implements IGradeRuleService
{
    @Resource
    private GradeRuleMapper gradeRuleMapper;

    /**
     * 查询等级规则
     * 
     * @param id 等级规则主键
     * @return 等级规则
     */
    @Override
    public GradeRule selectGradeRuleById(Long id)
    {
        return gradeRuleMapper.selectGradeRuleById(id);
    }

    /**
     * 查询等级规则列表
     * 
     * @param gradeRule 等级规则
     * @return 等级规则
     */
    @Override
    public List<GradeRule> selectGradeRuleList(GradeRule gradeRule)
    {
        return gradeRuleMapper.selectGradeRuleList(gradeRule);
    }

    /**
     * 新增等级规则
     * 
     * @param gradeRule 等级规则
     * @return 结果
     */
    @Override
    public int insertGradeRule(GradeRule gradeRule)
    {
        gradeRule.setCreateTime(DateUtils.getNowDate());
        return gradeRuleMapper.insertGradeRule(gradeRule);
    }

    /**
     * 修改等级规则
     * 
     * @param gradeRule 等级规则
     * @return 结果
     */
    @Override
    public int updateGradeRule(GradeRule gradeRule)
    {
        gradeRule.setUpdateTime(DateUtils.getNowDate());
        return gradeRuleMapper.updateGradeRule(gradeRule);
    }

    /**
     * 批量删除等级规则
     * 
     * @param ids 需要删除的等级规则主键
     * @return 结果
     */
    @Override
    public int deleteGradeRuleByIds(Long[] ids)
    {
        return gradeRuleMapper.deleteGradeRuleByIds(ids);
    }

    /**
     * 删除等级规则信息
     * 
     * @param id 等级规则主键
     * @return 结果
     */
    @Override
    public int deleteGradeRuleById(Long id)
    {
        return gradeRuleMapper.deleteGradeRuleById(id);
    }

    @Override
    public GradeRule checkGrade(Long pointsNum){
        return gradeRuleMapper.checkGrade(pointsNum);
    };
}
